package com.dating.base.vo;

import com.dating.base.bean.Permission;

/**
 * 
 * @description 内置的权限枚举
 */
public enum InstalledPermission {

	
	/**
	 * 首页
	 */
	ADMIN_MAIN("admin_main", "首页", true, null, "home", "main", "admin_main", 0),
	
	/**
	 * 访问控制
	 */
	SYS_SETTING("sys_setting", "系统设置", true, null, "cog", null, "sys_setting", 0),
	
	/**
	 * 用户列表
	 */
	USER_LIST("user_admin", "用户管理", true, SYS_SETTING.getName(), "user", "user/list",
			"user_admin", 1),
	/**
	 * 用户添加
	 */
	USER_ADD("user_add", "添加用户", false, USER_LIST.getName(), "plus-circle",
			"user/add", "user_admin", 2),
	/**
	 * 编辑用户
	 */
	USER_EDIT("user_edit", "编辑用户", false, USER_LIST.getName(), "pencil",
			"user/edit", "user_admin", 2),
	/**
	 * 用户删除
	 */
	USER_DELETE("user_delete", "删除用户", false, USER_LIST.getName(), "trash-o",
			"user/delete", "user_admin", 2),
	/**
	 * 角色管理
	 */
	ROLE_LIST("role_admin", "角色管理", true, SYS_SETTING.getName(), "eye", "role/list",
			"role_admin", 1),
	/**
	 * 角色添加
	 */
	ROLE_ADD("role_add", "添加角色", false, ROLE_LIST.getName(), "plus-circle",
			"role/add", "role_admin", 2),
	/**
	 * 编辑角色
	 */
	ROLE_EDIT("role_edit", "编辑角色", false, ROLE_LIST.getName(), "pencil",
			"role/edit", "role_admin", 2),
	/**
	 * 角色删除
	 */
	ROLE_DELETE("role_delete", "删除角色", false, ROLE_LIST.getName(), "trash-o",
			"role/delete", "role_admin", 2),
	/**
	 * 权限管理
	 */
	PERMISSION_LIST("permission_admin", "权限管理", true, SYS_SETTING.getName(), "lock",
			"permission/list", "permission_admin", 1)

	;

	/**
	 * 权限名
	 */
	private String name;
	/**
	 * 权限描述
	 */
	private String desc;
	/**
	 * 是否菜单标志
	 */
	private boolean menu;

	/**
	 * 前置权限id
	 */
	private String need;
	/**
	 * 菜单icon
	 */
	private String icon;
	/**
	 * 功能url
	 */
	private String url;
	/**
	 * 菜单的高亮关键词,和此功能页面设置的值一致
	 */
	private String key;

	/**
	 * 权限级别
	 */
	private int level;

	/**
	 * @param name
	 *            权限名称
	 * @param desc
	 *            描述(菜单/按钮显示文字)
	 * @param menu
	 *            是否菜单标志
	 * @param need
	 *            前置权限
	 * @param icon
	 *            图标
	 * @param url
	 *            功能url
	 * @param key
	 *            高亮关键字
	 * @param level
	 *            权限级别
	 */
	private InstalledPermission(String name, String desc, boolean menu,
			String need, String icon, String url, String key, int level) {
		this.name = name;
		this.desc = desc;
		this.menu = menu;
		this.need = need;
		this.url = url;
		this.key = key;
		this.level = level;
		this.icon = icon;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public boolean isMenu() {
		return menu;
	}

	public void setMenu(boolean menu) {
		this.menu = menu;
	}

	public String getNeed() {
		return need;
	}

	public void setNeed(String need) {
		this.need = need;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	/**
	 * 将枚举转换成权限对象
	 * 
	 * @return
	 */
	public Permission toPermission() {
		Permission permission = new Permission();
		permission.setDescription(desc);
		permission.setHilightKey(key);
		permission.setInstalled(true);
		permission.setLevel(level);
		permission.setMenu(menu);
		permission.setName(name);
		permission.setIcon(icon);
		permission.setNeedPermission(need);
		permission.setUrl(url);
		return permission;
	}
}
